/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Jayasundara
 */
@Entity
@Table(name = "project", catalog = "postgres", schema = "public")
@NamedQueries({@NamedQuery(name = "Project.findAll", query = "SELECT p FROM Project p"), @NamedQuery(name = "Project.findById", query = "SELECT p FROM Project p WHERE p.id = :id"), @NamedQuery(name = "Project.findByName", query = "SELECT p FROM Project p WHERE p.name = :name"), @NamedQuery(name = "Project.findByKey", query = "SELECT p FROM Project p WHERE p.key = :key"), @NamedQuery(name = "Project.findByDescription", query = "SELECT p FROM Project p WHERE p.description = :description")})
public class Project implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "name", length = 15)
    private String name;
    @Column(name = "key", length = 5)
    private String key;
    @Column(name = "description", length = 50)
    private String description;
    @JoinColumn(name = "default_assignee", referencedColumnName = "id")
    @ManyToOne
    private NamePrefix defaultAssignee;
    @JoinColumn(name = "lead_user", referencedColumnName = "id")
    @ManyToOne
    private User leadUser;
    @OneToMany(mappedBy = "projectId")
    private List<Component> componentCollection;

    public Project() {
    }

    public Project(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public NamePrefix getDefaultAssignee() {
        return defaultAssignee;
    }

    public void setDefaultAssignee(NamePrefix defaultAssignee) {
        this.defaultAssignee = defaultAssignee;
    }

    public User getLeadUser() {
        return leadUser;
    }

    public void setLeadUser(User leadUser) {
        this.leadUser = leadUser;
    }

    public List<Component> getComponentCollection() {
        return componentCollection;
    }

    public void setComponentCollection(List<Component> componentCollection) {
        this.componentCollection = componentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Project)) {
            return false;
        }
        Project other = (Project) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.me.entity.Project[id=" + id + "]";
    }

}
